﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Cole.Entities;
using Cole.Service;

namespace Cole.GUI
{
    public partial class frmListMatricula : Form
    {
        private IMatriculaService matriculaService;

        public frmListMatricula()
        {
            InitializeComponent();
            if (matriculaService == null)
                matriculaService = new MatriculaService();
        }

        private void btnBuscar_Click(object sender, EventArgs e)
        {
            LoadData();
        }

        private void LoadData()
        {
            var criterio = string.IsNullOrEmpty(txtCriterio.Text) ? "%" : txtCriterio.Text;

            matriculaDTOBindingSource.DataSource =
                matriculaService.GetAllFromMatriculasByCriterio(criterio);
        }

        private void frmListMatricula_Load(object sender, EventArgs e)
        {
            LoadData();
        }

        private void btnNuevo_Click(object sender, EventArgs e)
        {

        }

        private void btnEditar_Click(object sender, EventArgs e)
        {
            var matricula = matriculaDTOBindingSource.Current as MatriculaDTO;

            if (matricula != null)
            {
                var frmMatricula = new frmMatricula();
                frmMatricula.ShowDialog();
            }
        }

        private void btnEliminar_Click(object sender, EventArgs e)
        {
            var frmMatricula = new frmMatricula();
            frmMatricula.ShowDialog();
        }
    }
}
